<%@tag import="busterminalweb.authorization.User"%>
<%@tag description="naivgation bar" pageEncoding="UTF-8"%>
<%@taglib tagdir="/WEB-INF/tags/busterminal/" prefix="bt"%>
<%@taglib uri="/WEB-INF/tags/tlds/BusTerminalTagLibrary.tld" prefix="auth"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="/WEB-INF/tags/tlds/Functions.tld" prefix="f"%>

<div class="navbar navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container">
            <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </a>
            <a class="brand" href="${pageContext.servletContext.contextPath}"><i class="icon-road icon-white" style="margin-top: 5px;"></i>&nbsp;Bus Terminal</a>
            <div class="nav-collapse">
                <ul class="nav">
                    <%--
                        Notice!
                        All dynamic actions, like loading pages via load() function, modal windows, drop down menus, etc. requires "data-toggle" attribute.
                        Maybe, the better variant is to use data-toogle="tab"
                    --%>                                        

                    <c:set var="user" scope="session" value="${userAuth}" />
                    <c:if test="${ empty user}">
                        <c:set var="user" scope="session" value="${f:createUser('', '', '', 'PASSENGER')}" />
                    </c:if>

                    <c:if test="${ !empty user and f:isActionAllowed('bus.list', user.getRole()) }">
                        <li><a href="MainServlet?action=bus.list" id="bus-list" data-toggle="tab" class="pageLink">Bus list</a></li>
                    </c:if>                  
                    <c:if test="${ !empty user and f:isActionAllowed('bus.model.list', user.getRole()) }">
                        <li><a href="MainServlet?action=bus.model.list" id="bus-model-list" data-toggle="tab" class="pageLink">Bus model list</a></li>
                    </c:if>                  
                    <c:if test="${ !empty user and f:isActionAllowed('route.list', user.getRole()) }">
                        <li><a href="MainServlet?action=route.list" id="route-list" data-toggle="tab" class="pageLink">Route list</a></li>
                    </c:if>                  
                    <c:if test="${ !empty user and f:isActionAllowed('scheduled.item.list', user.getRole()) }">
                        <li><a href="MainServlet?action=scheduled.item.list" id="scheduled-item-list" data-toggle="tab" class="pageLink">Scheduled item list</a></li>
                    </c:if>                  
                    <c:if test="${ !empty user and f:isActionAllowed('stopping.point.list', user.getRole()) }">
                        <li><a href="MainServlet?action=stopping.point.list" id="stopping-point-list" data-toggle="tab" class="pageLink">Stopping point list</a></li>
                    </c:if>                  
                    <c:if test="${ !empty user and f:isActionAllowed('trip.list', user.getRole()) }">
                        <li><a href="MainServlet?action=trip.list" id="trip-list" data-toggle="tab" class="pageLink">Trip list</a></li>
                    </c:if>                  
                </ul>
                <ul class="nav pull-right" >
                    <li class="dropdown" id="auth-menu">
                        <a href="#auth-menu" class="dropdown-toggle" data-toggle="dropdown">Authorization<b class="caret"></b></a>
                        <ul class="dropdown-menu well">
                            <bt:Authorization />
                        </ul>
                    </li>
                </ul>
                <li class="divider-vertical"></li>
            </div>
        </div>
    </div>
</div>